import {IEventManager} from "./IEventManager";
import {EventPool} from "../Base/EventPool/EventPool";
import {EventPoolMode} from "../Base/EventPool/EventPoolMode";
import ccclass = cc._decorator.ccclass;
import GameFrameworkModule from "../Base/GameFrameworkModule";
import GameEventArgs from "./GameEventArgs";
@ccclass("EventManager")
export  default class EventManager implements IEventManager,GameFrameworkModule{
    private readonly  _eventPool:EventPool<GameEventArgs>;

    constructor() {
        this._eventPool = new EventPool<GameEventArgs>(EventPoolMode.AllowNoHandler | EventPoolMode.AllowMultiHandler);
    }

    Check(id: number, handler): boolean {
        return  this._eventPool.Check(id,handler);
    }

    Count(id: number): number {
        return this._eventPool.Count(id);
    }

    EventCount(): number {
        return this._eventPool.EventCount;
    }

    EventHandlerCount(): number {
        return this._eventPool.EventHandlerCount;
    }

    Fire(sender, e): void {
        this._eventPool.Fire(sender,e);
    }

    FireNow(sender, e): void {
        this._eventPool.FireNow(sender,e);
    }

    get Priority(): number {
        return 1000;
    }

    SetDefaultHandler(handler): void {
        this._eventPool.SetDefaultHandler(handler);
    }

    Shutdown(): void {
        this._eventPool.Shutdown();
    }

    Subscribe(id: number, handler): void {
        this._eventPool.Subscribe(id,handler);
    }

    Unsubscribe(id: number, handler): void {
        this._eventPool.Unsubscribe(id,handler);
    }

    Update(elapseSeconds: number, realElapseSeconds: number): void {
        this._eventPool.Update(elapseSeconds,realElapseSeconds);
    }

    get baseName(): string {
        return "GameFrameworkModule";
    }

}